const {
	onDblClickRow,
	requestTestMethod,
} = require('./parameter-methods')

module.exports = function initRequestParameter(apiTestComp) {
	let {
		requestParameterComp,
	} = apiTestComp
	let flag = 'req'
	requestParameterComp.treegrid({
		title: '请求参数',
		fit: true,
		fitColumns: true,
		treeField: 'name',
		lines: true,
		idField: '_treeId_',
		dblclickToEdit: false,
		clickToEdit: false,
		columns: [
			[{
				field: 'name',
				title: '变量名',
				width: 30,
			}, {
				field: 'content',
				title: '含义',
				width: 40,
			}, {
				field: 'type',
				title: '类型',
				width: 30,
			}, {
				field: 'value',
				title: '值',
				width: 30,
				editor: {
					type: 'textbox',
					options: {

					}
				}
			}]
		],
		toolbar: [{
			iconCls: 'icon-tip',
			text: '请求测试',
			handler: function() {
				requestTestMethod.call(apiTestComp)
			}
		}],

		/**
		 * 双击开始编辑行
		 * @param  {[type]} row [description]
		 * @return {[type]}     [description]
		 */
		onDblClickRow(row) {
			onDblClickRow.call(apiTestComp, row)
		},
	});
}